//
//  ListCell.m
//  quickBatchManager
//
//  Created by jack on 15/9/23.
//  Copyright (c) 2015年 jack. All rights reserved.
//

#import "ListCell.h"
#import "EditProductViewController.h"
@implementation ListCell

@synthesize contentView;
- (void)awakeFromNib {
    contentView.layer.borderWidth = 1;
    contentView.layer.borderColor = [UIColor grayColor].CGColor;
    
    [_editBtn bk_whenTapped:^{
        EditProductViewController *vc=[[EditProductViewController alloc] init];
        vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
        vc.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
        _parentVC.definesPresentationContext = YES;
        [_parentVC presentViewController:vc animated:YES completion:nil];
    }];
    
    _deleteBtn.userInteractionEnabled = YES;
    [_deleteBtn bk_whenTapped:^{
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"是否删除产品" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"删除", nil];
        [alertView show];
    }];
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        // 初始化时加载collectionCell.xib文件
        NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"ListCell" owner:self options:nil];
        
        // 如果路径不存在，return nil
        if (arrayOfViews.count < 1)
        {
            return nil;
        }
        // 如果xib中view不属于UICollectionViewCell类，return nil
        if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]])
        {
            return nil;
        }
        // 加载nib
        self = [arrayOfViews objectAtIndex:0];
    }
    
    return self;
}
@end
